<?php
include_once('./base/xcx_sqlclass.php');
include_once('./base/xcx_commonclass.php');
$fun=new commonfun();
$mysql=new MMsql();
if(isset($_POST['rqtype'])){
	$rqtype=$_POST['rqtype'];//请求来源
}
if(isset($_POST['wkid'])){
	$wkid=$_POST['wkid'];//班级标记
}
if(isset($_POST['userid'])){
	$userid=$_POST['userid'];
}
if(isset($_POST['pageNum'])){
	$pageNum=$_POST['pageNum'];
	$pageSize=$_POST['pageSize'];
	$allCount=($pageNum - 1) * $pageSize;
}
//$sql="select video_url from wk_videos where user_id='".$userid."'";
/*
*请求我的视频资源
*/
if($rqtype=="mysource"){
	$sql="select video_url from wk_videos
	where user_id = '".$userid."' and Id >= (select Id from wk_videos where user_id = '".$userid."'  limit $allCount,1 ) 
	limit 0,$pageSize ";
	$result=$mysql->doSql($sql);
	echo json_encode($result);
}
/*
*请求班级视频资源
*/
if($rqtype=="wksource"){
	$sql="select * from wk_videos
	where wk_id = '".$wkid."' and Id >= (select Id from wk_videos where wk_id = '".$wkid."'  and  TO_DAYS(ctime) = TO_DAYS(now()) limit $allCount,1 ) 
	limit 0,$pageSize ";
	$result=$mysql->doSql($sql);
	if(count($result)>0){
		$aa=substr($wkid,0,6);//截用户id标记
		if($userid==$aa){
			echo json_encode($result);
		}else{
			$ret=[];
			foreach($result as $item){
				if($item['video_type']==0 or $item['user_id']==$userid){//学生获取公开的和自己的
					$ret[]=$item;
				}
			}
			echo json_encode($ret);
		}
		
	}else{
		echo json_encode($result);
	}
	
}

